#{extends 'sidebar.html' /}
<div class="frontTitle">Project Invitations:</div>
<div class="frontInv">
#{if invitations.isEmpty()}
#{note} There are no new project invitations#{/note}
#{/if}
#{else}

#{list items:invitations, as:'inv'}
	<div id = "pinv_${inv.id}">
		<img src="/public/images/famfam/user_go.png"/><font color="white">You have been invited to be ${inv.role} in project <a onclick="showProjectWorkspace(${inv.role.project.id})">${inv.role.project.name}</a> by <b>${inv.invitedBy.name}</b></font>
		<br><a onclick="javascript: inv_respond('${inv.id}', '${inv.hash}', 1);"><img src="/public/images/famfam/tick.png" title="Confirm"/></a> &nbsp; 
		<a onclick="javascript: inv_respond('${inv.id}', '${inv.hash}', 0);"><img src="/public/images/famfam/cross.png" title="Decline"/></a>
	</div>
#{/list}
#{/else}
</div>
<div class="frontTitle">Meeting Invitations:</div>
<div class="frontInv">
#{if meetings.isEmpty()}
#{note} There are no new meeting invitations#{/note}
#{/if}
#{else}
#{list items:meetings, as:'meet'}
	<div id = "meet_${meet.meeting.id}" style="display:block">
		<img src="/public/images/famfam/meeting.png"/><font color="white">You have been invited to attend meeting: <a onclick = "showProjectWorkspace(${meet.meeting.project.id});loadBox('/meetings/viewmeetings?id=${meet.meeting.project.id}','workspace-${meet.meeting.project.id}','reload-meetings-${meet.meeting.project.id}')">${meet.meeting.name}</a> in project <a onclick="showProjectWorkspace(${meet.meeting.project.id})">${meet.meeting.project.name}</a> by <b>${meet.invitedBy.name}</b></font>
		<br><a onclick="confirm_me('${meet.meeting.id}');"><img src="/public/images/famfam/tick.png" title="Accept"/></a> &nbsp; 
		<a onclick="decline_me('${meet.meeting.id}');"><img src="/public/images/famfam/cross.png" title="Decline"/></a>
	</div>
#{/list}
#{/else}
</div>
<script type = text/javascript>
	function inv_respond(id, hash, res)
	{
		if(res == 1)
			$.post('@{respondInvite()}',
					{what:true, hash:hash, id:id},
					function()
					{
						$('#pinv_'+id).html('<img src="/public/images/famfam/tick.png" /> <font color="white">Invitation confirmed</font>');
					}					
					);
		else
			$.post('@{respondInvite()}',
					{what:false, hash:hash, id:id},
					function()
					{
						$('#pinv_'+id).html('<img src="/public/images/famfam/cross.png" /> <font color="white">Invitation declined</font>');
					}					
					);		
	}	
</script>
